import { SaaSTenantNameListItem, SaaSTenantUserListItem, SaaSTenantUserPageParams } from './model/enterpriseAdminModel';
import { tenantHttp } from '/@/utils/http/axios';

interface AdminUserInfo {
  email: string;
  id: number;
  tenantName: string;
  isBuiltIn: string;
  password: string;
  isUpdateEmail: boolean;
  isUpdatePhone: boolean;
  name: string;
  phone: string;
  status: number;
  createdTime: string;
}

enum Api {
  SaaSTenantUserList = '/tenant/getTenantUserList',
  SaaSTenantNameList = '/tenant/getTenantNameList',
  UpdateAdminUser = '/tenant/updateTenantAdministrator',
}

// 分页获取企业管理员
export const getSaaSTenantUserList = (params: SaaSTenantUserPageParams) => {
  // 获取企业管理员列表
  return tenantHttp.get<SaaSTenantUserListItem[]>({
    url: Api.SaaSTenantUserList,
    params,
  });
};

// 获取所有企业
export const getSaaSTenantNameList = () => {
  return tenantHttp.get<SaaSTenantNameListItem[]>({
    url: Api.SaaSTenantNameList,
  });
};

// 更新企业管理员
export const updateAdminUser = (data: AdminUserInfo) => {
  return tenantHttp.put<SaaSTenantNameListItem[]>({
    url: Api.UpdateAdminUser,
    data,
  });
};
